#/bin/bash
Url=http://mirror.cnop.net
#System 
if [ -e /etc/redhat-release ]; then
    OS=CentOS
	echo -e "\033[32m $OS $OS_Ver \033[0m"
	Command="yum -y install gcc wget make cmake gcc-c++  bzip2 openssl-devel libX11-devel"
   [ -n "$(grep ' 7\.' /etc/redhat-release 2> /dev/null)" ] && OS_Ver=7
   [ -n "$(grep ' 6\.' /etc/redhat-release 2> /dev/null)" ] && OS_Ver=6
   
  elif [ -n "$(grep -i 'Debian' /etc/issue 2> /dev/null)" ]; then
    OS=Debian
	Command="apt-get install make wget cmake gcc g++ openssl-devel libX11-devel"
	echo -e "\033[32m $OS $OS_Ver \033[0m"
  elif [ -n "$(grep -i 'Ubuntu' /etc/issue 2> /dev/null)" ]; then
    OS=Ubuntu
	echo -e "\033[32m $OS $OS_Ver \033[0m" 
	Command="apt-get install make wget cmake gcc g++ openssl-devel libX11-devel"
  else
    echo "UnknownOS"
	Command=" "
	exit
fi
#install 
$Command && wget $Url/rdesktop/rdesktop-1.8.3.tar.gz && tar zxvf rdesktop-1.8.3.tar.gz && cd rdesktop-1.8.3
./configure --disable-credssp --disable-smartcard
make && make install
cd .. && rm -rf rdesktop*
echo -e "\033[32m Done. \033[0m"